---
description: "Reference for Nitric's v0 Node.js library - Set the value of a document"
---

# Node.js - collection.doc.set()

Set the value of a document.

```javascript
import { collection } from '@nitric/sdk'

const profiles = collection('profiles').for('writing')

const drakesProfile = profiles.doc('Drake Mallard')

await drakesProfile.set({
  firstName: 'Drake',
  lastName: 'Mallard',
})
```

## Parameters

<Properties>
  <Property name="document" required type="object">
    The document to set on the key
  </Property>
</Properties>

## Examples

### Set a document

```javascript
import { collection } from '@nitric/sdk'

const profiles = collection('profiles').for('writing')

const drakesProfile = profiles.doc('Drake Mallard')

await drakesProfile.set({
  firstName: 'Drake',
  lastName: 'Mallard',
})
```

### Update a document

```javascript
import { collection } from '@nitric/sdk'

const profiles = collection('profiles').for('reading', 'writing')

const drakesProfile = profiles.doc('Drake Mallard')

const existingProfile = await drakesProfile.get()

await drakesProfile.set({
  ...existingProfile,
  firstName: 'Drake',
})
```

### See also

- [doc.get()](./collection-doc-get)
- [doc.delete()](./collection-doc-delete)
